package com.cheetah.enums;

import com.cheetah.constants.ProtocolConstants;

import java.util.HashMap;
import java.util.Map;

public enum Protocol {

    PROTOBUFF(ProtocolConstants.PROTOCOL_MAGIC_PROTO,"protobuf");

    private  String name;

    private short code;






    private Protocol(short code, String name){
        this.code = code;
        this.name = name;
    }

    public String getName(){
        return this.name;
    }

    public short getCode(){
        return this.code;
    }


    private static Map<Short,Protocol> map = new HashMap<>();

    static {
        for (Protocol p : Protocol.values()){
            map.put(p.code, p);
        }
    }

    public static Protocol getProtocol(short code) {
        return map.get(code);
    }

}
